package cn.com.bluemoon.daps.standard.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.com.bluemoon.daps.common.enums.ReferRulesType;
import cn.com.bluemoon.daps.common.enums.StandardDataType;
import cn.com.bluemoon.daps.standard.dto.AddCheck;
import cn.com.bluemoon.daps.standard.dto.IExcelSourceModel;
import cn.com.bluemoon.daps.standard.dto.UpdateCheck;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * <p>
 * 基础标准表
 * </p>
 *
 * @author admin
 * @since 2020-08-03
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "DapStandardBasic", description = "基础标准表")
public class DapStandardBasic extends BasePublishInfoOfStandard<DapStandardBasic> implements IExcelSourceModel {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "业务定义")
    @NotNull(message = "[业务定义]不可为空")
    @Size(max = 1024, message = "业务定义不可以大于{max}", groups = {AddCheck.class, UpdateCheck.class})
    @Excel(name = "业务定义")
    private String businessDefine;

    @ApiModelProperty(value = "数据长度，大于1")
    @Excel(name = "数据长度")
    @Size(max = 100, message = "数据长度不可以大于{max}", groups = {AddCheck.class, UpdateCheck.class})
    private String dataLength;

    @ApiModelProperty(value = "数据精度，小数位数多少")
    @Excel(name = "数据精度")
    @Size(max = 100, message = "数据精度不可以大于{max}", groups = {AddCheck.class, UpdateCheck.class})
    private String dataScale;

    /**
     * 数据类型
     * 代码类 标志类 文本类 金额类 比例类 数值类 日期类 日期时间类
     * <strong>当{@link DapStandardBasic#getDataType()}为{@link StandardDataType#代码类}</strong>
     * 时，才会有所谓的代码字典{@link DapStandardBasicDic},其他不需要存储代码字典
     */
    @EnumValue
    @ApiModelProperty(value = "数据类型, eg: 0: 代码类,1: 标志类,2: 文本类,3: 金额类,4: 比例类,5: 数值类,6: 日期类,7: 日期时间类,8: 时间类 ")
    private StandardDataType dataType;

    @TableField(exist = false)
    @ApiModelProperty(hidden = true)
    @Excel(name = "数据类型")
    private String dataTypeStr;
    /**
     * 对应的主管部门 {@link DapSystemDepartment#getId()}
     */
    @ApiModelProperty(value = "关联主管部门id")
    @NotBlank(message = "部门信息不可为空", groups = {AddCheck.class, UpdateCheck.class})
    private String departmentId;

    @ApiModelProperty(value = "英文名")
    @Excel(name = "*英文名称")
    @NotBlank(message = "[英文名]不可为空", groups = {AddCheck.class, UpdateCheck.class})
    @Size(max = 50, message = "[英文名称]不可以大于{max}", groups = {AddCheck.class, UpdateCheck.class})
    private String engName;

    @ApiModelProperty(value = "中文名")
    @Excel(name = "*中文名称")
    @Size(max = 50, message = "[中文名称]不可以大于{max}", groups = {AddCheck.class, UpdateCheck.class})
    @NotBlank(message = "[中文名称]不可为空", groups = {AddCheck.class, UpdateCheck.class})
    private String name;

    /**
     * 指定依据
     * {@link ReferRulesType#getCode()}
     */
    @EnumValue
    @ApiModelProperty(value = "制定依据, eg: 1: 国家标准 2：行内标准 3：内部标准")
    private ReferRulesType referRules;

    @ApiModelProperty(value = "所属主题")
    @NotBlank(message = "[所属主题]不可为空", groups = {AddCheck.class, UpdateCheck.class})
    private String topicId;

    @ApiModelProperty(value = "一级分类")
    @NotBlank(message = "[一级分类]不可为空", groups = {AddCheck.class, UpdateCheck.class})
    private String firstCategory;

    @ApiModelProperty(value = "2级分类")
    private String secondCategory;

    @ApiModelProperty(value = "3级分类")
    private String thirdCategory;

    @ApiModelProperty(value = "引用代码，英文名")
    @Excel(name = "引用代码")
    private String sourceCode;

    @ApiModelProperty(value = "取值范围")
    @Excel(name = "取值范围（码表值域）")
    private String valueRange;


}
